import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import AutoImport from 'unplugin-auto-import/vite'
import { ElementPlusResolver  } from "unplugin-vue-components/resolvers";
import basicSsl from '@vitejs/plugin-basic-ssl'
import { VantResolver } from '@vant/auto-import-resolver';
// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern-compiler', // or 'modern'
      },
    },
  },
  base: "/zhkp_h5/", // 应用的基路径，影响资源和路由的基准URL
  plugins: [vue(), AutoImport({
    include: [
      /\.[tj]sx?$/,
      /\.vue$/,
      /\.vue\?vue/,
      /\.md$/,
    ],
    imports: ['vue', 'vue-router', 'pinia'],
    //注意这个配置和src同级
    dts: './auto-imports.d.ts',
    resolvers: [VantResolver(),ElementPlusResolver()]
  }),
  Components({ resolvers: [VantResolver(),ElementPlusResolver()] })],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server:{
    // host:"192.168.137.64",
    proxy: {
      '/mhlrjApi': {
        target: "https://mhlrj.shmh.gov.cn/zhkp",
        changeOrigin: true, // 是否更改请求来源
        // rewrite: (path) => path.replace(/^\/HQ_ZHSY_API/, '/HQ_ZHSY_API') // 重写路径
      }
    }
  }
});
